package com.example.shiwuyouproject.ui.pup

import android.content.Context
import android.view.View
import com.bigkoo.pickerview.adapter.ArrayWheelAdapter
import com.contrarywind.view.WheelView
import com.example.shiwuyouproject.R
import com.lxj.xpopup.core.BottomPopupView

class TimePickPopup(context: Context, var onItem: onTimeOnClickListener): BottomPopupView(context) {

    override fun getImplLayoutId(): Int {
        return R.layout.popup_timepick
    }

    val mOptionsItemsHour: MutableList<String> = ArrayList()
    val mOptionsItemsMinute: MutableList<String> = ArrayList()
    private var startHour: WheelView?=null
    private var startMinute: WheelView?=null
    private var endHour: WheelView?=null
    private var endMinute: WheelView?=null
    private var stStartHour=""
    private var stStartMinute=""
    private var stEndHour=""
    private var stEndMinute=""

    override fun initPopupContent() {
        super.initPopupContent()
        startHour=findViewById(R.id.options1)
        startMinute=findViewById(R.id.options2)
        endHour=findViewById(R.id.options3)
        endMinute=findViewById(R.id.options4)
        startHour?.setTextColorCenter(context.resources.getColor(R.color.color_445DFD))
        startMinute?.setTextColorCenter(context.resources.getColor(R.color.color_445DFD))
        endHour?.setTextColorCenter(context.resources.getColor(R.color.color_445DFD))
        endMinute?.setTextColorCenter(context.resources.getColor(R.color.color_445DFD))
        for(i in 0..23){//小时
            if(i<10){
                mOptionsItemsHour.add("0$i")
            }else{
                mOptionsItemsHour.add(i.toString())
            }
        }
        for(i in 0..59){
            if(i<10){
                mOptionsItemsMinute.add("0$i")
            }else{
                mOptionsItemsMinute.add(i.toString())
            }
        }
        startHour?.adapter = ArrayWheelAdapter(mOptionsItemsHour)
        startMinute?.adapter = ArrayWheelAdapter(mOptionsItemsMinute)
        endHour?.adapter = ArrayWheelAdapter(mOptionsItemsHour)
        endMinute?.adapter = ArrayWheelAdapter(mOptionsItemsMinute)
        findViewById<View>(R.id.tvCancel).setOnClickListener { dismiss() }
        findViewById<View>(R.id.tvCenter).setOnClickListener { //确定

        }


    }
   interface  onTimeOnClickListener{
        fun onTimeBack()
    }
}